 #include <pcl/io/openni_grabber.h>
 #include <pcl/visualization/cloud_viewer.h>
 #include <iostream>
 #include <pcl/io/pcd_io.h>
 #include <pcl/point_types.h>
 #include <pcl/features/vfh.h>

 class SimpleOpenNIViewer
 {
   public:
     SimpleOpenNIViewer () : viewer ("PCL OpenNI Viewer") {}

     void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloudx)
     {
       pcl::io::savePCDFileBinary ("scene.pcd", *cloudx);
     }

     void run ()
     {
       pcl::Grabber* interface = new pcl::OpenNIGrabber();

       boost::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f =
         boost::bind (&SimpleOpenNIViewer::cloud_cb_, this, _1);

       interface->registerCallback (f);
       interface->start ();
	   boost::this_thread::sleep(boost::posix_time::seconds(1.2));
       interface->stop ();
     }

     pcl::visualization::CloudViewer viewer;
 };

 int captureScreen ()
 {
   SimpleOpenNIViewer v;
   v.run ();
   //boost::this_thread::sleep(boost::posix_time::seconds(2));
   return 0;
 }